package demo04.personOperation.service;

import demo04.personOperation.daoImpl.PersonDaoImpl;
import demo04.personOperation.pojo.Person;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class PersonService {

    PersonDaoImpl pdi = new PersonDaoImpl();

    /**
     * 添加单条数据
     * @param person
     * @return
     */
    public boolean insert(Person person){
        List<Person> people = new ArrayList<>();
        people.add(person);
        return insert(people);
    }

    /**
     * 添加不定长形式的多条数据
     * @param person
     * @return
     */
    public boolean insert(Person... person){
        List<Person> people = Arrays.asList(person);
        return insert(people);
    }

    /**
     * 添加集合形式的多条数据
     * @param person
     * @return
     */
    public boolean insert(List<Person> person){
        return pdi.insert(person);
    }


    public boolean update(Person person){
        return pdi.update(person);
    }


    public boolean delete(String[] person) {
        return pdi.delete(person);
    }

    public List<Person> getAll() {
        return pdi.getAll();
    }
}
